<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head> 
    <meta charset="UTF-8">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script type="text/javascript">
     $(document).ready(function() {
    	showAddRowBtn();
    	$("select").select2();
    	onClickTd();
    });
    
    // 添加行按钮制御
    function showAddRowBtn(){
    	if($("#tableIndentList tr").length>0 && $("#tableCartonList tr").length>0){
    		$("#btnAddRow").show();
    		$("#btnSave").show();
    	}else{
    		$("#btnAddRow").hide();
    		$("#btnSave").hide();
    	}
    }
    
    // 选择纸箱回调
    function selectCartonCallBack(commaCartonId){
		if(commaCartonId != null && commaCartonId != '' && commaCartonId != "undefined"){
			$("#commaCartonId").val(commaCartonId);
	    	// 格式化，去除逗号
	 	    var params = $("#inputForm").serialize();
	        // 调用后台更新数据
	        $.post("${ctx}/enchase/single/addCarton",params,function(result) {
	            // 回调函数赋值
	            var h = $(callBackHtml(result)).find("#tableCartonList").html();
	            $('#tableCartonList').html(h);
	            
	            // 回调函数赋值
	            var h = $(callBackHtml(result)).find("#tablePackageDetailsList").html();
	            $('#tablePackageDetailsList').html(h);
	            
	            $("select").select2();
	            
	            onClickTd();
	            
		    	// 添另行按钮制御
		    	showAddRowBtn();
		    	
	        }, 'html');
		}
    }
    
    // 合同订单选择回调
    function selectIndentCallBack(indentId){
		if(indentId != null && indentId != '' && indentId != "undefined"){
		        // 调用后台更新数据
		        $.post("${ctx}/enchase/single/indentList?indentId="+indentId,'',function(result) {
		            // 回调函数赋值
		            var h = $(callBackHtml(result)).find("#tableIndentList").html();
		            $('#tableIndentList').html(h);
		            
		            var h = $(callBackHtml(result)).find("#trHeadPackageDetailsSize").html();
		            $('#trHeadPackageDetailsSize').html(h);
		            
		            // 回调函数赋值
		            var h = $(callBackHtml(result)).find("#tablePackageDetailsList").html();
		            $('#tablePackageDetailsList').html(h);
		            
		            getStyleInfoAllColor();
		            
		            $("select").select2();
		            
		            cartonAllQuantity();
		            
		            sumAllValue();
		            
			    	// 添另行按钮制御
			    	showAddRowBtn();
		        }, 'html');
		}
    }
    
    // 取得款式信息里所有的颜色
    function getStyleInfoAllColor() {
    	var arr =  $("#tableIndentList").find(".styleInfoColor");
    	var arrList = new Array();
    	if(arr!=null && arr.length>0){
 	    	$.each(arr, function(i, item){
	    		if($.inArray($(this).text(),arrList)==-1){
	    		   arrList.push($(this).text());
	    		}
	    	});
    	}
    	$("#colorList").val(arrList);
    }
    
    // 添加装箱单明细
    function addRowPackageDetails(){
    	    getStyleInfoAllColor();
	 	    var params = $("#inputForm").serialize();
	        // 调用后台更新数据
	        $.post("${ctx}/enchase/single/addRowPackageDetails",params,function(result) {
	            // 回调函数赋值
	            var h = $(callBackHtml(result)).find("#tablePackageDetailsList").html();
	            $('#tablePackageDetailsList').html(h);
	            
	            $("select").select2();
	            onClickTd();
	            showAddRowBtn();
	        }, 'html');
    }
    
    // 单击箱体明细尺码
	function onClickTd() {
	    $("#tablePackageDetailsList").find("td[class^='subSize']").on("click",function(){
	    	
	    	// ***尺码起始位置
	    	var sizeIndext = 12;
	    	
	        var index = $(this).parent().index();
            var cellIndex = $(this)[0].cellIndex;
            
            var gColorName = $("#tablePackageDetailsList tr").eq(index).find(".selectPackageListColor").eq(1).val();
            var gSizeName = $("#trHeadPackageDetailsSize th").eq(cellIndex-sizeIndext).text();

	    	if(!hasColorSize(gColorName,gSizeName)){
	    		return false;
	    	}
	    	
	    	//找到当前鼠标单击的td
	        var tdObj = $(this);
	        //创建一个文本框
	        var inputTemp = "<input tyle = 'text' value = '"+$(this).text()+"'  maxlength = '4'>";
	        var inputObj = $(inputTemp);
	        $(inputObj).keyup(function(){
	        	this.value=this.value.replace(/\D/g,'');
	        });
            
	        //去掉文本框的边框  
	        inputObj.css("border-width", 0);
	        inputObj.click(function () {
	            return false;
	        });
	        //使文本框的宽度和td的宽度相同  
	        inputObj.width(tdObj.width()-5);
	        inputObj.height(tdObj.height()-14);;
	        //去掉文本框的外边距 
	        inputObj.css("margin", 0);
	        inputObj.css("padding", 0);
	        //把文本框放到td中  
	        tdObj.html(inputObj);
	        //文本框失去焦点的时候变为文本  
	        inputObj.blur(function () {
	            var newText = $(this).val();
	            $("#tablePackageDetailsList tr").eq(index).find(".hiddenSubSize").eq(cellIndex-sizeIndext).val(newText);
	            tdObj.html(newText);
	            oneCartonQuantity(index);
	        });
	        //全选  
	        inputObj.trigger("focus").trigger("select");
	   });
	}
    
    // 判断颜色尺码
    function hasColorSize(fColorName,fSizeName) {

         var number = 0;
         // 从页面获取值 进行比较
         $("#tableIndentList tr").each(function(j){
          if ((fColorName == $(this).find('.styleInfoColor').text()) && (fSizeName == $(this).find('.styleInfoSizeName').text())) {
                 number = number+1;
          }
         });
        
         if (number> 0) {
            return true;
         } else {
            return false;
         }
    }
    
    // 颜色变更后，所有尺码清空
    function clearAllSizeNum(trIndex){
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenSubSize").val('');
    	$("#tablePackageDetailsList tr").eq(trIndex).find("[class^='subSize']").text('');
    	
    	oneCartonQuantity(trIndex);
    }
    
    // 格式化
    function formatInputNumber(inputObj,trIndex,decimalPoint){
    	var replaceVal = 0;
    	// 有小数
    	if(decimalPoint>0){
	       var strRegex = /^(-?\d+)(\.\d+)?$/;
	       if(strRegex.test($(inputObj).val())){
	    	   replaceVal = $(inputObj).val();
	       }
    	}else{
    		if($(inputObj).val().replace(/\D/g,'') != ''){
         	   replaceVal = $(inputObj).val().replace(/\D/g,'');
    		}
    	}
    	
    	$(inputObj).val(replaceVal);
    }
    
    // 删除箱单明细
    function deletePackageDetials(trIndex){
    	getStyleInfoAllColor();
    	$("#trIndex").val(trIndex);
    	var fFrom = parseInt($("#tablePackageDetailsList tr").eq(trIndex).find(".inputPackageListCartonNoFrom").val());
    	var fTo = parseInt($("#tablePackageDetailsList tr").eq(trIndex).find(".inputPackageListCartonNoTo").val());
 	    var params = $("#inputForm").serialize();
        // 调用后台更新数据
        $.post("${ctx}/enchase/single/delPackageDetail",params,function(result) {
            // 回调函数赋值
            var h = $(callBackHtml(result)).find("#tablePackageDetailsList").html();
            $('#tablePackageDetailsList').html(h);
            
            $("select").select2();
            onClickTd();
            
        	// 设定箱号存在flg
        	setSameCartonNoFlg(trIndex,fFrom,fTo);
            
            // 待装箱
            waitCartonQuantity();
            // 纸箱数
            cartonAllQuantity();
        	// 计算总值
        	sumAllValue();
        	
            if($("#tablePackageDetailsList tr").length==0){
        		$("#btnSave").hide();
            }
            
        }, 'html');
    }
    
    
    // 净重改变
    function changeNetWeight(inputObj,trIndex){
    	// 格式化
    	formatInputNumber(inputObj,trIndex,5);
    	
    	// 计算总值
    	sumAllValue();
    }
    
    // 改变箱数
    function changeDetailsCartonNumber(trIndex){
    	var fFrom = parseInt($("#tablePackageDetailsList tr").eq(trIndex).find(".inputPackageListCartonNoFrom").val());
    	var fTo = parseInt($("#tablePackageDetailsList tr").eq(trIndex).find(".inputPackageListCartonNoTo").val());
    	if(fFrom==0 || fTo==0){
    		return;
    	}
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".tdPackageListCartonQuantity").text(fTo-fFrom+1);
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListCartonQuantity").val(fTo-fFrom+1);
    	
    	countMoreCarton(trIndex);
    }
    
    // 箱单明细-箱号form改变
    function changeCartonFromTo(inputObj,trIndex){
    	
    	// 格式化
    	formatInputNumber(inputObj,trIndex,0);
    	
    	// 改变箱数
    	changeDetailsCartonNumber(trIndex);
    	
    	// 设定箱号存在flg
    	var fFrom = parseInt($("#tablePackageDetailsList tr").eq(trIndex).find(".inputPackageListCartonNoFrom").val());
    	var fTo = parseInt($("#tablePackageDetailsList tr").eq(trIndex).find(".inputPackageListCartonNoTo").val());
    	setSameCartonNoFlg(trIndex,fFrom,fTo);
    	
    	// 计算纸箱总数
    	cartonAllQuantity();
    	
    	// 待装箱数
    	waitCartonQuantity();
    	
    	// 计算总值
    	sumAllValue();
    }
    
    // 箱号是否存在,设定箱号存在flg
    function setSameCartonNoFlg(trIndex,pFrom,pTo){

    	var arr = $("#tablePackageDetailsList tr");
    	var sameFlg = 0;
    	$.each(arr, function(i, item){
    		var rowFrom = parseInt($(item).find(".inputPackageListCartonNoFrom").val());
    		var rowTo = parseInt($(item).find(".inputPackageListCartonNoTo").val());
     		if(rowFrom == pFrom && rowTo == pTo){
     			if(sameFlg==0){
     				$("#tablePackageDetailsList tr").eq(i).find(".hiddenPackageListSameCartonFlg").val(0);
     				sameFlg = 1;
     			}else{
     				$("#tablePackageDetailsList tr").eq(i).find(".hiddenPackageListSameCartonFlg").val(1);
     			}
    		}
    	});    	
    }
    
    // 每箱件
    function oneCartonQuantity(trIndex){
    	var arr = $("#tablePackageDetailsList tr").eq(trIndex).find(".subSize");
    	var vCount = 0;
    	$.each(arr, function(i, item){
    		var sizeQuantity = $(item).text();
    		if(sizeQuantity == null || sizeQuantity == '' || sizeQuantity == "undefined"){
    			sizeQuantity = 0;
    		}
    		
    		vCount = vCount + parseInt(sizeQuantity);
    	});
    	
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".tdPackageListSingleCarton").text(vCount);
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListSingleCarton").val(vCount);
    	
    	countMoreCarton(trIndex);
    	
    	waitCartonQuantity();
    	
    	sumAllValue();
    }
    
    // 明细总件数
    function countMoreCarton(trIndex){
    	var fSingCarton = $("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListSingleCarton").val();
    	var fCartonQuantity = $("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListCartonQuantity").val();
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".tdPackageListMoreCarton").text(parseInt(fSingCarton)*parseInt(fCartonQuantity));
    	$("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListMoreCarton").val(parseInt(fSingCarton)*parseInt(fCartonQuantity));
    	
    }
    // 待装箱数
    function waitCartonQuantity(){
    	var arrIndentList = $("#tableIndentList tr");
    	var arrDetailsList = $("#tablePackageDetailsList tr");
    	
    	$.each(arrIndentList, function(i, itemIndent){
    		var indentColor = $(itemIndent).find(".styleInfoColor").text();
    	    var indentSize = $(itemIndent).find(".styleInfoSizeName").text();
    	    var waitCount = 0;
    	    
    		$.each(arrDetailsList, function(j, itemDetails){
    			var detailsColor = $(itemDetails).find(".selectPackageListColor").eq(1).val();
    			if(indentColor == detailsColor){
    			   var arrDetailsSizeName = $(itemDetails).find(".hiddenSubSizeName");
    			   var sizeIndex = 9999;
    			   $.each(arrDetailsSizeName, function(k, itemSize){
    				   var detailsSizeName = $(itemSize).val();
    				   if(detailsSizeName != null && detailsSizeName != '' && detailsSizeName != "undefined"){
	    				   if(indentSize == detailsSizeName){
	    					   sizeIndex = k;
	    				   }
    				   }
    			   });
    			   
    			   if(sizeIndex!=9999){
    				   var tempCount = $(itemDetails).find(".hiddenSubSize").eq(sizeIndex).val();
    		    		if(tempCount == null || tempCount == '' || tempCount == "undefined"){
    		    			waitCount += 0;
    		    		}else{
    		    			var tempPackageNum = $(itemDetails).find(".hiddenPackageListCartonQuantity").val();
    				        waitCount = waitCount + parseInt(tempCount)*tempPackageNum;
    		    		}
    			   }
    			}
    		});
    		var old = $(itemIndent).find(".hiddenIndentListIndentNumber").val();
    		$(itemIndent).find(".tdIndentListUnPackNumber").text(old-waitCount);
    		$(itemIndent).find(".hiddenIndentListUnPackNumber").val(old-waitCount);
    	});
    }
    // 纸箱总数
    function cartonAllQuantity(){
    	var arrCartonList = $("#tableCartonList tr");
    	var arrDetailsList = $("#tablePackageDetailsList tr");
    	
    	$.each(arrCartonList, function(i, itemCarton){
    		var vCartonId = $(itemCarton).find(".hiddenCartonInfoListId").val();
    		var vCount = 0;
    		$.each(arrDetailsList, function(j, itemDetails){
    			var detailsCartonId = $(itemDetails).find(".selectPackageListCartonId").eq(1).val();
    			var detailsCartonFlg = $(itemDetails).find(".hiddenPackageListSameCartonFlg").val();
   			    if(vCartonId == detailsCartonId && detailsCartonFlg==0){
 				   var tempCount = $(itemDetails).find(".hiddenPackageListCartonQuantity").val();
 				   vCount += parseInt(tempCount);
   			    }
    		});
    		$(itemCarton).find(".tdCartonInfoListCartonNumber").text(vCount);
    		$(itemCarton).find(".hiddenCartonInfoListCartonNumber").val(vCount);
    	});
    }
    
    // 纸箱名称改变
    function changeSelectPackageListCarton(trIndex){
    	var detailsCartonId = $("#tablePackageDetailsList tr").eq(trIndex).find(".selectPackageListCartonId").eq(1).val();
    	var arrCartonList = $("#tableCartonList tr");
    	$.each(arrCartonList, function(i, itemCarton){
    		var vCartonId = $(itemCarton).find(".hiddenCartonInfoListId").val();
    		if(vCartonId != null && vCartonId != '' && vCartonId != "undefined"){
    			if(vCartonId==detailsCartonId){
    				var vVolume = $(itemCarton).find(".hiddenCartonInfoListCartonVolume").val();
    				var vWeight = $(itemCarton).find(".hiddenCartonInfoListCartonWeight").val();
    				$("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListBoxVolume").val(vVolume);
    				$("#tablePackageDetailsList tr").eq(trIndex).find(".hiddenPackageListBoxWeight").val(vWeight);
    			}
    		}
    	});
    	
    	cartonAllQuantity();
    	sumAllValue();
    }
    
    // 计算 所有总数(总件数,总箱数,总毛重,总净重,总体积)
    function sumAllValue(){
    	var arr = $("#tablePackageDetailsList tr");
    	// 总件数
    	var vPackageStyleQuantity = 0;
    	// 总箱数
    	var vPackageQuantity = 0;
    	// 总净重
    	var vPackageNetWeight = 0.00;
    	// 总体积
    	var vPackageVolume = 0.00;
    	// 总毛重
    	var vPackageRoughWeight = 0.00;
    	
    	$.each(arr, function(i, item){
       		// 总箱数
       		var eachPackageQuantity = parseInt($(item).find(".hiddenPackageListCartonQuantity").val());
       		
    		// 总件数
    		var eachPackageStyleQuantity = parseInt($(item).find(".hiddenPackageListMoreCarton").val());
    		vPackageStyleQuantity += eachPackageStyleQuantity;
    		
    		// 总净重
    		var eachPackageNetWeight = Math.formatFloat(parseFloat($(item).find(".telPackageListCartonNetWeight").val())*eachPackageQuantity,2);
    		vPackageNetWeight = Math.formatFloat((vPackageNetWeight + eachPackageNetWeight),2);
    		
    		var detailsCartonFlg = $(item).find(".hiddenPackageListSameCartonFlg").val();
    		if(detailsCartonFlg==0){
    			// 总箱数
        		vPackageQuantity += eachPackageQuantity;
        		// 总体积
        		var eachPackageListBoxVolume = parseFloat($(item).find(".hiddenPackageListBoxVolume").val());
        		vPackageVolume = Math.formatFloat(vPackageVolume + (eachPackageListBoxVolume * eachPackageQuantity),2);
   		    	// 箱子重量
    		    var eachPackageRoughWeight = parseFloat($(item).find(".hiddenPackageListBoxWeight").val());
        		vPackageRoughWeight = Math.formatFloat(vPackageRoughWeight + (eachPackageRoughWeight * eachPackageQuantity),2);
    		}
        });
    	// 总件数
    	$("#pagePackageStyleValue span").find(".pagePackageStyleQuantity").text(vPackageStyleQuantity);
    	$("#packageStyleQuantity").val(vPackageStyleQuantity);
    	
    	// 总箱数
    	$("#pagePackageStyleValue span").find(".pagePackageQuantity").text(vPackageQuantity);
    	$("#packageQuantity").val(vPackageQuantity);
    	
    	// 总毛重
    	$("#pagePackageStyleValue span").find(".pagePackageRoughWeight").text(Math.formatFloat((vPackageRoughWeight+vPackageNetWeight),2));
    	$("#packageRoughWeight").val(Math.formatFloat((vPackageRoughWeight+vPackageNetWeight),2));
    	
    	// 总净重
    	$("#pagePackageStyleValue span").find(".pagePackageNetWeight").text(vPackageNetWeight);
    	$("#packageNetWeight").val(vPackageNetWeight);
    	
    	// 总体积
    	$("#pagePackageStyleValue span").find(".pagePackageVolume").text(vPackageVolume);
    	$("#packageVolume").val(vPackageVolume);
    }
    
	Math.formatFloat = function(f, digit) { 
		var s = f;
		//判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
		var numberVerification = /^[0-9]+.?[0-9]*$/;   
		if (numberVerification.test(s)){
			s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(digit) + "";  
		}else{
			s = 0;
		}
	    return parseFloat(s); 
	}
	
    //保存方法
    var saveForm={
         t:null,
         save:function(t){
        	 if (!confirm('<spring:message code="common_save"/>')) {
        		 return;
        	 }
        	 
        	 var hasSize = isEmptyStyleQuantity();
        	 if(hasSize){
        		 layer.msg('<spring:message code="enchase_pleaseInputSize"/>', {time:1000});
        		 return;
        	 }
        	 
             $(t).attr("disabled",true);
             this.t=t;

	       	 // 格式化，去除逗号
	         formUnFormat($("#inputForm"));
	         // 从表单获取数据信息
	         var params = $("#inputForm").serialize();
	         // 调用后台保存方法
	         $.post("${ctx}/enchase/single/save",params,function(result){
	             // 提示信息
	             tipParent(result.message);
	             // 返回状态
	             if(result.statusCode==STATUSCODEOK){
	                  window.parent.frames[0].searchListForm();
	                  closeWin(); 
	             }else{
	                  $(saveForm.t).attr("disabled",false);
	             }
	         },'json'); 
         } 
    }
    
    // 每箱尺寸搭配,必须入力
    function isEmptyStyleQuantity(){
    	
    	var arr = $("#tablePackageDetailsList tr");
    	
    	if($("#tablePackageDetailsList tr").length==0){
    		return true;
    	}
    	
    	var hasFlg = false;
    	$.each(arr, function(i, item){
    		var subSizeList = $(item).find(".hiddenSubSize");
    		var roHasFlg = false;
    		if(subSizeList.length==0){
    			hasFlg = true;
    		}else{
	    		$.each(subSizeList, function(j, itemSize){
	        		var temp = $(itemSize).val();
	        		if(temp!=null && temp!='' && temp!="undefined" && parseInt(temp)>0){
	        		   roHasFlg = true;
	        		}
	    		});
	    		
	    		if(!roHasFlg){
	    		   hasFlg = true;
	    		}
    		}
    	});
    	
    	return hasFlg;
    }
    </script> 
</head>
<body>   
<div class="layerHeader clearfix">
	<p class="headerTitle"><spring:message code="enchase_create_title"/></p>
    <div class="headerButton clearfix">
        <button type="button" onclick="popup('650px','519px','${ctx}/enchase/single/cartonSelect')"><spring:message code="enchase_create_btn_selectCarton"/></button>
        <button type="button" onclick="popup('800px','519px','${ctx}/purchase/handbook/indentSelect')"><spring:message code="enchase_create_btn_selectStyle"/></button>
        <button type="button" id="btnSave" onclick="saveForm.save(this)"><spring:message code="common_save"/></button>
        <button type="button" onclick="closeWin()"><spring:message code="btn_cancle"/></button>
    </div>
</div>
<form id="inputForm" method="post" >
<c:set value="<%=ResourcesUtil.getConfig(\"customer_country\")%>" var="customerCountry" />
<c:set value="<%=ResourcesUtil.getConfig(\"package_style\")%>" var="packageStyle" />
<input type="hidden" id="colorList" name="colorList" value="${enchase.colorList}"/>
<input type="hidden" id="commaCartonId" name="commaCartonId" value="${enchase.commaCartonId}"/>
<input type="hidden" id="trIndex" name="trIndex" value="${enchase.trIndex}"/>
<input type="hidden" id="packageStyleQuantity" name="packageStyleQuantity" value="${enchase.packageStyleQuantity}"/>
<input type="hidden" id="packageQuantity" name="packageQuantity" value="${enchase.packageQuantity}"/>
<input type="hidden" id="packageRoughWeight" name="packageRoughWeight" value="${enchase.packageRoughWeight}"/>
<input type="hidden" id="packageNetWeight" name="packageNetWeight" value="${enchase.packageNetWeight}"/>
<input type="hidden" id="packageVolume" name="packageVolume" value="${enchase.packageVolume}"/>
<input type="hidden" id="id" name="id" value="${enchase.id}"/>
<div class="tabBoxSm">
 <div class="tabSm smOrderBox">
  <div style="height:180px;">
    <!-- 款式信息 -->
    <div class="left col-50">
         <p style="margin-top:0;margin-bottom:5px;margin-left:20px;"><span style="font-size:16px;"><spring:message code="enchase_show_styleInfo_title"/></span></p>
         <div class="tableArea">
        	<div class="tableScroll tableScrollSm" style="width:470px;height:142px;">
        		<table cellpadding="0" class="tableHead">
                    <thead>
                    <tr>	
                        <!-- No. -->	
                    	<th style="width:30px;"><spring:message code="enchase_show_styleInfo_no"/></th>
                    	<!-- 合同单号 -->
                        <th><p style="width:80px;"><spring:message code="enchase_show_styleInfo_customerContractNo"/></p></th>
                        <!-- 款式编号 -->
                        <th><p style="width:80px;"><spring:message code="enchase_show_styleInfo_customerStyleNo"/></p></th>
                        <!-- 颜色 -->
                        <th style="width:70px;"><spring:message code="enchase_show_styleInfo_color"/></th>
                        <!--尺码  -->
                        <th style="width:50px;"><spring:message code="enchase_show_styleInfo_size"/></th>
                        <!-- 总件数 -->
                        <th style="width:70px;"><spring:message code="enchase_show_styleInfo_allQuantity"/></th>
                        <!-- 待装箱数 -->
                        <th style="width:70px;"><spring:message code="enchase_show_styleInfo_waitQuantity"/></th>
                    </tr>
                    </thead>
                </table>
                <table cellpadding="0" class="tableBody" id="tableIndentList">
                <c:if test="${not empty enchase.indentList}">
                    <tbody>
                    <c:forEach items="${enchase.indentList}" var="indentInfo" varStatus="status">
                    <tr>
                        <!-- NO -->
                    	<td style="width:30px;">${status.index+1}</td>
                    	<!-- 合同单号 -->
                        <td><p style="width:80px;" class="text_overflow" data-toggle='tooltip' title='${indentInfo.customerContractNo}'>${indentInfo.customerContractNo}</p></td>
                        <input type="hidden" name="indentList[${status.index}].customerContractNo" value="${indentInfo.customerContractNo}"/>
                        <!-- 客户款式编号 -->
                        <td><p style="width:80px;" class="text_overflow" data-toggle='tooltip' title='${indentInfo.styleCustomerNo}'>${indentInfo.styleCustomerNo}</p></td>
                        <input type="hidden" name="indentList[${status.index}].styleCustomerNo" value="${indentInfo.styleCustomerNo}"/>
                        <!-- 颜色 -->
                        <td style="width:70px;" class="styleInfoColor">${indentInfo.cartonColorName}</td>
                        <input type="hidden" name="indentList[${status.index}].cartonColorName" value="${indentInfo.cartonColorName}"/>
                        <!-- 尺码 -->
                        <td style="width:50px;" class="styleInfoSizeName">${indentInfo.sizeName}</td>
                        <input type="hidden" name="indentList[${status.index}].sizeName" value="${indentInfo.sizeName}"/>
                        <!-- 总件数 -->
                        <td style="width:70px;"><fmt:formatNumber value="${indentInfo.indentNumber}" pattern="#,##0"/></td>
                        <input  class="hiddenIndentListIndentNumber" type="hidden" name="indentList[${status.index}].indentNumber" value="${indentInfo.indentNumber}"/>
                        <!-- 待装箱数 -->
                        <td class="tdIndentListUnPackNumber" style="width:70px;"><fmt:formatNumber value="${indentInfo.unPackNumber}" pattern="#,##0"/></td>
                        <input class="hiddenIndentListUnPackNumber" type="hidden" name="indentList[${status.index}].unPackNumber" value="${indentInfo.unPackNumber}"/>
                        <!-- 订单id -->
                        <td class="none">${indentInfo.indentId}</td>
                        <input type="hidden" name="indentList[${status.index}].indentId" value="${indentInfo.indentId}"/>
                        <!-- 合同id -->
                        <td class="none">${indentInfo.contractId}</td>
                        <input type="hidden" name="indentList[${status.index}].contractId" value="${indentInfo.contractId}"/>
                        <!-- 款式id -->
                        <td class="none">${indentInfo.styleId}</td>
                        <input type="hidden" name="indentList[${status.index}].styleId" value="${indentInfo.styleId}"/>
                        <!-- 尺码cd -->
                        <td class="none">${indentInfo.cartonSizeCd}</td>
                        <input type="hidden" name="indentList[${status.index}].cartonSizeCd" value="${indentInfo.cartonSizeCd}"/>
                        <!-- 尺码组cd -->
                        <td class="none">${indentInfo.styleSizeGroupCd}</td>
                        <input type="hidden" name="indentList[${status.index}].styleSizeGroupCd" value="${indentInfo.styleSizeGroupCd}"/>                         
                    </tr>
                    </c:forEach>
                    </tbody>
                </c:if>
                </table>
            </div>
        </div>
    </div>
    <!-- 纸箱信息 -->
    <div class="right col-50">
         <p style="margin-top:0;margin-bottom:5px;margin-left:20px;"><span style="font-size:16px;"><spring:message code="enchase_show_cartonInfo_title"/></span></p>
         <div class="tableArea">
        	<div class="tableScroll tableScrollSm" style="width:484px;height:142px;">
        		<table cellpadding="0" class="tableHead">
                    <thead>
                    <tr>
                        <!-- No. -->
                    	<th style="width:30px;"><spring:message code="enchase_show_cartonInfo_no"/></th>
                    	<!-- 箱体名称 -->
                        <th style="width:100px;"><spring:message code="enchase_show_cartonInfo_cartonName"/></th>
                        <!-- 长 -->
                        <th style="width:55px;"><spring:message code="enchase_show_cartonInfo_length"/></th>
                        <!-- 宽 -->
                        <th style="width:55px;"><spring:message code="enchase_show_cartonInfo_width"/></th>
                        <!-- 高 -->
                        <th style="width:55px;"><spring:message code="enchase_show_cartonInfo_height"/></th>
                        <!-- 体积 -->
                        <th style="width:55px;"><spring:message code="enchase_show_cartonInfo_volume"/></th>
                        <!-- 箱重 -->
                        <th style="width:55px;"><spring:message code="enchase_show_cartonInfo_weight"/></th>
                        <!-- 总数 -->
                        <th style="width:60px;"><spring:message code="enchase_show_cartonInfo_allQuantity"/></th>
                    </tr>
                    </thead>
                </table>
                <table cellpadding="0" class="tableBody" id="tableCartonList">
                <c:if test="${not empty enchase.cartonInfoList}">
                    <tbody>
                    <c:forEach items="${enchase.cartonInfoList}" var="cartonInfo" varStatus="status">
                    	<tr>
                    	    <!-- NO -->
							<td style="width:30px;">${status.index+1}</td>
							<!-- 箱体名称 -->
							<td style="width:100px;">${cartonInfo.cartonName}</td>
							<input type="hidden" name="cartonInfoList[${status.index}].cartonName" value="${cartonInfo.cartonName}"/>
							<!-- 长 -->
							<td style="width:55px;"><fmt:formatNumber value="${cartonInfo.cartonLength}" pattern="#,##0.####"/></td>
							<input type="hidden" name="cartonInfoList[${status.index}].cartonLength" value="${cartonInfo.cartonLength}"/>
							<!-- 宽 -->
							<td style="width:55px;"><fmt:formatNumber value="${cartonInfo.cartonWidth}" pattern="#,##0.####"/></td>
							<input type="hidden" name="cartonInfoList[${status.index}].cartonWidth" value="${cartonInfo.cartonWidth}"/>
							<!-- 高 -->
							<td style="width:55px;"><fmt:formatNumber value="${cartonInfo.cartonHeight}" pattern="#,##0.####"/></td>
							<input type="hidden" name="cartonInfoList[${status.index}].cartonHeight" value="${cartonInfo.cartonHeight}"/>
							<!-- 体积 -->
							<td style="width:55px;"><fmt:formatNumber value="${cartonInfo.cartonVolume}" pattern="#,##0.####"/></td>
							<input class="hiddenCartonInfoListCartonVolume" type="hidden" name="cartonInfoList[${status.index}].cartonVolume" value="${cartonInfo.cartonVolume}"/>
							<!-- 箱重 -->
							<td style="width:55px;"><fmt:formatNumber value="${cartonInfo.cartonWeight}" pattern="#,##0.####"/></td>
							<input class="hiddenCartonInfoListCartonWeight" type="hidden" name="cartonInfoList[${status.index}].cartonWeight" value="${cartonInfo.cartonWeight}"/>
							<!-- 总数 -->
							<td class="tdCartonInfoListCartonNumber" style="width:60px;"><fmt:formatNumber value="${cartonInfo.cartonNumber}" pattern="#,##0"/></td>
							<input class="hiddenCartonInfoListCartonNumber" type="hidden" name="cartonInfoList[${status.index}].cartonNumber" value="${cartonInfo.cartonNumber}"/>
							<!-- id -->
							<td class="none">${cartonInfo.id}</td>
							<input class="hiddenCartonInfoListId" type="hidden" name="cartonInfoList[${status.index}].id" value="${cartonInfo.id}"/>
						</tr>
					</c:forEach>	
                    </tbody>
                </c:if>    
                </table>
            </div>
        </div>
    </div>
  </div>
  <div>
      <div class="items clearfix" id="pagePackageStyleValue">
	      <p style="margin-top:0;margin-bottom:0px;margin-left:10px;"><span style="font-size:16px;"><spring:message code="enchase_show_package_title"/></span>
	      <button type="button" id="btnAddRow" onclick="addRowPackageDetails()"><spring:message code="enchase_create_btn_addRow"/></button>
	      <span style="color:#d6392d;right:650px;position:absolute;"><spring:message code="enchase_show_package_allStyleQuantity"/><span class="pagePackageStyleQuantity"><fmt:formatNumber value="${enchase.packageStyleQuantity}" pattern="#,##0"/></span></span>
	      <span style="color:#d6392d;right:500px;position:absolute;"><spring:message code="enchase_show_package_allCartonQuantity"/><span class="pagePackageQuantity"><fmt:formatNumber value="${enchase.packageQuantity}" pattern="#,##0"/></span></span>
	      <span style="color:#d6392d;right:350px;position:absolute;"><spring:message code="enchase_show_package_allRoughtWeight"/><span class="pagePackageRoughWeight"><fmt:formatNumber value="${enchase.packageRoughWeight}" pattern="#,##0.####"/></span></span>
	      <span style="color:#d6392d;right:200px;position:absolute;"><spring:message code="enchase_show_package_allNetWeight"/><span class="pagePackageNetWeight"><fmt:formatNumber value="${enchase.packageNetWeight}" pattern="#,##0.####"/></span></span>
	      <span style="color:#d6392d;right:50px;position:absolute;"><spring:message code="enchase_show_package_allVolume"/><span class="pagePackageVolume"><fmt:formatNumber value="${enchase.packageVolume}" pattern="#,##0.####"/></span></span>
	      </p>
      </div>
      <div class="tableArea">
     	<div class="tableScroll tableScrollSm" style="width:963px;height:281px;">
     		<table cellpadding="0" class="tableHead" style="z-index: 9999">
                 <thead>
                 <tr>
                     <!-- 操作 -->
                 	 <th rowSpan="2" style="width:30px;"><spring:message code="enchase_show_package_operate"/></th>
                 	 <!-- 合同单号 -->
                     <th rowSpan="2"><p style="width:70px;"><spring:message code="enchase_show_package_customerContractNo"/></p></th>
                     <!-- 款式编号 -->
                     <th rowSpan="2"><p style="width:70px;"><spring:message code="enchase_show_package_customerStyleNo"/></p></th>
                     <!-- 国别 -->
                     <th rowSpan="2" style="width:60px;"><spring:message code="enchase_show_package_country"/></th>
                     <!-- 包装类型 -->
                     <th rowSpan="2" style="width:60px;"><spring:message code="enchase_show_package_packageStyle"/></th>
                     <!-- 颜色 -->
                     <th rowSpan="2" style="width:60px;"><spring:message code="enchase_show_package_color"/></th>
                     <!-- 箱号 -->
                     <th rowSpan="2" style="width:70px;"><spring:message code="enchase_show_package_cartonNo"/></th>
                     <!-- 箱数 -->
                     <th rowSpan="2" style="width:50px;"><spring:message code="enchase_show_package_cartonQuantity"/></th>
                     <!-- 箱体名称 -->
                     <th rowSpan="2" style="width:60px;"><spring:message code="enchase_show_package_cartonName"/></th>
                     <!-- 每箱件 -->
                     <th rowSpan="2" style="width:50px;"><spring:message code="enchase_show_package_singleQuantity"/></th>
                     <!-- 净重 -->
                     <th rowSpan="2" style="width:40px;"><spring:message code="enchase_show_package_netWeight"/></th>
                     <!-- 总件数 -->
                     <th rowSpan="2" style="width:50px;"><spring:message code="enchase_show_package_allQuantity"/></th>
                     <!-- 每箱尺寸搭配 -->
                     <th colSpan="8" style="width:272px;"><spring:message code="enchase_show_package_cartonSize"/></th>
                 </tr>
                 <tr id="trHeadPackageDetailsSize">      
                     <th style="width:34px;">${enchase.allSizeList[0].sizeName}</th>
                     <input type="hidden" name="allSizeList[0].sizeName" value="${enchase.allSizeList[0].sizeName}"/>
                     <input type="hidden" name="allSizeList[0].cartonSizeCd" value="${enchase.allSizeList[0].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[1].sizeName}</th>
                     <input type="hidden" name="allSizeList[1].sizeName" value="${enchase.allSizeList[1].sizeName}"/>
                     <input type="hidden" name="allSizeList[1].cartonSizeCd" value="${enchase.allSizeList[1].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[2].sizeName}</th>
                     <input type="hidden" name="allSizeList[2].sizeName" value="${enchase.allSizeList[2].sizeName}"/>
                     <input type="hidden" name="allSizeList[2].cartonSizeCd" value="${enchase.allSizeList[2].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[3].sizeName}</th>
                     <input type="hidden" name="allSizeList[3].sizeName" value="${enchase.allSizeList[3].sizeName}"/>
                     <input type="hidden" name="allSizeList[3].cartonSizeCd" value="${enchase.allSizeList[3].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[4].sizeName}</th>
                     <input type="hidden" name="allSizeList[4].sizeName" value="${enchase.allSizeList[4].sizeName}"/>
                     <input type="hidden" name="allSizeList[4].cartonSizeCd" value="${enchase.allSizeList[4].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[5].sizeName}</th>
                     <input type="hidden" name="allSizeList[5].sizeName" value="${enchase.allSizeList[5].sizeName}"/>
                     <input type="hidden" name="allSizeList[5].cartonSizeCd" value="${enchase.allSizeList[5].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[6].sizeName}</th>
                     <input type="hidden" name="allSizeList[6].sizeName" value="${enchase.allSizeList[6].sizeName}"/>
                     <input type="hidden" name="allSizeList[6].cartonSizeCd" value="${enchase.allSizeList[6].cartonSizeCd}"/>
                     <th style="width:34px;">${enchase.allSizeList[7].sizeName}</th>
                     <input type="hidden" name="allSizeList[7].sizeName" value="${enchase.allSizeList[7].sizeName}"/>
                     <input type="hidden" name="allSizeList[7].cartonSizeCd" value="${enchase.allSizeList[7].cartonSizeCd}"/>
                 </tr>
                 </thead>
             </table>
             <table cellpadding="0" class="tableBody" >
                 <tbody>
                 <tr>
                     <td style="width:30px;"></td>
                     <td><p style="width:70px;"></p></td>
                     <td><p style="width:70px;"></p></td>
                     <td style="width:60px;"></td>
                     <td style="width:60px;"></td>
                     <td style="width:60px;"></td>
                     <td style="width:70px;"></td>
                     <td style="width:50px;"></td>
                     <td style="width:60px;"></td>
                     <td style="width:50px;"></td>
                     <td style="width:40px;"></td>
                     <td style="width:50px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                     <td style="width:34px;"></td>
                 </tr>
                 </tbody>
             </table>
             <table cellpadding="0" id="tablePackageDetailsList">
                <c:if test="${not empty enchase.packageDetailsList}">
                    <tbody>
                    <c:forEach items="${enchase.packageDetailsList}" var="packageDetailsInfo" varStatus="status">
                    <tr>
                        <!-- 删除 -->
                        <td style="width:30px;"><img src="/ls-qc/static/images/del_icon.png" class="delBtn" onclick='deletePackageDetials(${status.index})'></td>
                        <!-- 合同单号 -->
                        <td><p style="width:70px;" class="text_overflow" data-toggle='tooltip' title='${packageDetailsInfo.customerContractNo}'>${packageDetailsInfo.customerContractNo}</p></td>
                        <input type="hidden" name="packageDetailsList[${status.index}].customerContractNo" value="${packageDetailsInfo.customerContractNo}"/>
                        <!-- 款式编号 -->
                        <td><p style="width:70px;" class="text_overflow" data-toggle='tooltip' title='${packageDetailsInfo.styleCustomerNo}'>${packageDetailsInfo.styleCustomerNo}</p></td>
                        <input type="hidden" name="packageDetailsList[${status.index}].styleCustomerNo" value="${packageDetailsInfo.styleCustomerNo}"/>
                        <!-- 国别 -->
                        <td>
	     					<select name="packageDetailsList[${status.index}].countryCd" style="width:59px;">
	                            <c:forEach items="${fns:getDictList(customerCountry)}" var="country">
	                               <option <c:if test="${fn:split(packageDetailsInfo.countryCd,'-')[1] eq country.itemValue}">selected="selected"</c:if> value="${country.itemCode}-${country.itemValue}">
	                                 ${country.itemName}
	                               </option>
	                            </c:forEach>                    
	                         </select>
                        </td>
                        <!-- 包装类型 -->
                        <td>
                        	<select name="packageDetailsList[${status.index}].packageStyle" style="width:59px;">
	                            <c:forEach items="${fns:getDictList(packageStyle)}" var="pStyle">
	                               <option <c:if test="${fn:split(packageDetailsInfo.packageStyle,'-')[1] eq pStyle.itemValue}">selected="selected"</c:if> value="${pStyle.itemCode}-${pStyle.itemValue}">
	                                 ${pStyle.itemName}
	                               </option>
	                            </c:forEach>                    
	                         </select>
                        </td>
                        <!-- 颜色 -->
                        <td>
                           <select class="selectPackageListColor" name="packageDetailsList[${status.index}].cartonColorName" style="width:59px;" onChange="clearAllSizeNum(${status.index})">
                                <c:forEach items="${enchase.colorList}" var="selectColor">
                                    <option <c:if test="${packageDetailsInfo.cartonColorName eq selectColor}">selected="selected"</c:if> value="${selectColor}" >
                                       ${selectColor}
                                    </option>
                                </c:forEach>
                           </select>
                        </td>
                        <!-- 箱号 -->
                        <td style="width:70px;"><input class="inputPackageListCartonNoFrom" type="text" style="width:30px;display:inline" name="packageDetailsList[${status.index}].cartonNoFrom" value="${packageDetailsInfo.cartonNoFrom}" onblur="changeCartonFromTo(this,${status.index});" maxlength="5" >~<input class="inputPackageListCartonNoTo" type="text" style="width:30px;display:inline" name="packageDetailsList[${status.index}].cartonNoTo" value="${packageDetailsInfo.cartonNoTo}" onblur="changeCartonFromTo(this,${status.index});" maxlength="5">
                        </td>
                        <!-- 箱数 -->
                        <td class="tdPackageListCartonQuantity" style="width:50px;">${packageDetailsInfo.cartonQuantity}</td>
                        <input class="hiddenPackageListCartonQuantity" type="hidden" name="packageDetailsList[${status.index}].cartonQuantity" value="${packageDetailsInfo.cartonQuantity}"/>
                        <!-- 箱体名称 -->
                        <td>
                           <select class="selectPackageListCartonId" name="packageDetailsList[${status.index}].cartonId" style="width:59px;" onChange="changeSelectPackageListCarton(${status.index})">
                                <c:forEach items="${enchase.cartonInfoList}" var="selectPackageName">
                                    <option <c:if test="${packageDetailsInfo.cartonId eq selectPackageName.id}">selected="selected"</c:if> value="${selectPackageName.id}" >
                                       ${selectPackageName.cartonName}
                                    </option>
                                </c:forEach>
                           </select>
                        </td>
                        <!-- 每箱件 -->
                        <td class="tdPackageListSingleCarton" style="width:50px;">${packageDetailsInfo.singleCarton}</td>
                        <input class="hiddenPackageListSingleCarton" type="hidden" name="packageDetailsList[${status.index}].singleCarton" value="${packageDetailsInfo.singleCarton}"/>
                        <!-- 净重 -->
                        <td style="width:40px;"><input class="telPackageListCartonNetWeight" type="tel" name="packageDetailsList[${status.index}].cartonNetWeight" value="<fmt:formatNumber value="${packageDetailsInfo.cartonNetWeight}" pattern="##0.##"/>"  onblur="changeNetWeight(this,${status.index});" maxlength="8"></td>
                        <!-- 总件数 -->
                        <td class="tdPackageListMoreCarton" style="width:50px;">${packageDetailsInfo.moreCarton}</td>
                        <input class="hiddenPackageListMoreCarton" type="hidden" name="packageDetailsList[${status.index}].moreCarton" value="${packageDetailsInfo.moreCarton}"/>
                        <!-- 尺码明细 -->
                        <c:forEach items="${packageDetailsInfo.allSizeList}" var="packageDetailsSizeInfo" varStatus="sizeStatus">
                        <!-- 尺码 -->
                        <c:if test="${not empty packageDetailsSizeInfo.sizeName}">
                            <td class="subSize" style="width:34px;">${packageDetailsSizeInfo.cartonStyleQuantity}</td>
                            <input class="hiddenSubSize" type="hidden" name="packageDetailsList[${status.index}].allSizeList[${sizeStatus.index}].cartonStyleQuantity" value="${packageDetailsSizeInfo.cartonStyleQuantity}"/>
                            <input class="hiddenSubSizeName" type="hidden" name="packageDetailsList[${status.index}].allSizeList[${sizeStatus.index}].sizeName" value="${packageDetailsSizeInfo.sizeName}"/>
                            <input class="hiddenSubSizeCd" type="hidden" name="packageDetailsList[${status.index}].allSizeList[${sizeStatus.index}].cartonSizeCd" value="${packageDetailsSizeInfo.cartonSizeCd}"/>
                        </c:if>
                        <c:if test="${empty packageDetailsSizeInfo.sizeName}">
                            <td style="width:34px;background-color:#e4e4e4;"></td>
                            <input type="hidden" name="packageDetailsList[${status.index}].allSizeList[${sizeStatus.index}].cartonSizeCd" value="${packageDetailsSizeInfo.cartonSizeCd}"/>
                        </c:if>
                        </c:forEach>
	                    <!-- 箱号是否存在（前行） -->
	                    <input class="hiddenPackageListSameCartonFlg" type="hidden" name="packageDetailsList[${status.index}].hasCartonFromTo" value="${packageDetailsInfo.hasCartonFromTo}"/>
	                    <!-- 纸箱体积 -->
	                    <input class="hiddenPackageListBoxVolume" type="hidden" name="packageDetailsList[${status.index}].boxVolume" value="${packageDetailsInfo.boxVolume}"/>
	                    <!-- 纸箱重量 -->
	                    <input class="hiddenPackageListBoxWeight" type="hidden" name="packageDetailsList[${status.index}].boxWeight" value="${packageDetailsInfo.boxWeight}"/>
                    </tr>
                    </c:forEach>
                    </tbody>
                </c:if>   
             </table>
         </div>
      </div>
  </div>
 </div>
</div>
</form>
</body>
</html>